/******************************

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <iostream>
//for setw, precision()
#include <iomanip>
using namespace std;
#define max 20

class Node{
	int value;
	Node * next;
public:
	Node(){};
	Node(int n, Node *ne):value(n),next(ne){};
	Node * getNext(){
		return next;
	};
	int getValue(){
		return value;
	}
	void setValue(int v){
		value = v;
	}
	void setNext(Node * n){
		next = n;
	}
};
class Stack{
	Node *first, *p;
public:
	Stack(){
		first = NULL;
		p= NULL;
	}
	void nhap(){
		cout<<"\nNhap: ";
		do{
			cout<<"\nNhap ptu:";
			int t;
			cin>>t;
			if(t==-1){
				break;
			}
			if(push(t)<0){
				cout<<"\nFUll!";
			}

		}while(1);
	}

	void nhap2(){
		p = first = NULL;
		cout<<"\nNhap: ";
		int t;
		do
		{
			cout<<"\nNhap ptu: ";
			cin>>t;
			if (t != -1)
			{
				p = new Node(t, p);
				first = p;
			}
		} while (t != -1);
	}
	int isFull(){
		int n = 0;p = first;
		while (p != NULL)
		{
			n++;
			p = p->getNext();
		}
		return ((n+1) >= max) ?1 :0;
	}
	int isEmpty(){
		return (first==NULL)?1:0;
	}
	void show(){
		while (p)
		{
			cout<<p->getValue()<<" ";
			p = p->getNext();
		}
	}
	int push(int n){
		if (!isFull())
		{
			p = new Node(n,first);
			first = p;
			return 1;
		}
		return -1;
	}
	int pop(){
		if (!isEmpty())
		{
			int n = first->getValue();
			p = first;
			first = first->getNext();
			delete p;
			return n;
		}
		return -1;
	}
	void clear(){
		while (first != NULL)
		{
			p = first;
			first = first->getNext();
			delete p;
		}
	}
};

class BaseN:public Stack{
	int source;
	long des;
public:
	void nhapInput(){
		cout<<"\nNhap dau vao: ";
		cin>>source;
	}
	void toBin(){
		clear();
		int n = source;
		while (n > 0)
		{
			push(n %2);
			n/=2;
		}
		cout<<"\nSang binary: ";
		while (!isEmpty())
		{
			int n = pop();
			cout<<n;
		}
	}

	void toHex(){
		clear();
		int n = source;
		while (n > 0)
		{
			push(n %16);
			n/=16;
		}
		cout<<"\nSang hexa: ";
		while (!isEmpty())
		{
			int n = pop();
			switch (n)
			{
			case 0:
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
			case 9:
				cout<<n;
				break;
			case 10:
				cout<<'A';
				break;
			case 11:
				cout<<'B';
				break;
			case 12:
				cout<<'C';
				break;
			case 13:
				cout<<'D';
				break;
			case 14:
				cout<<'E';
				break;
			case 15:
				cout<<'F';
				break;
			default:
				break;
			}

		}
	}
};
void main(){
	BaseN b;
	b.nhapInput();
	//b.toBin();
	b.toHex();
	getch();

}

/**********************************/